package nongchang.kuaijiecaifu.com.ncapp_android.ui;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ezy.lite.util.ContextUtil;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.activity.BaseActivity;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Address;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter.AddressListAdapter;

public class UserChangeAddressActivity extends BaseActivity {
    @BindView(R.id.list)
    RecyclerView list;
    private AddressListAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_change_address);
        ButterKnife.bind(this);
        adapter=new AddressListAdapter(this);
        list.setAdapter(adapter);
        load();
    }

    private void load() {
        List<Address> list=new ArrayList<>();
        Address item=null;
        for(int i=0;i<3;i++) {
            item = new Address();
            item.address="地址："+i;
            item.name="名字："+i;
            item.phone="电话："+i;
            if(i==0){
                item.isdefault=true;
            }else{
                item.isdefault=false;
            }
            list.add(item);
        }
        adapter.update(list);
    }

    @OnClick({R.id.txt_add_address, R.id.btn_back})
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.txt_add_address:
                ContextUtil.startActivity(this, UserChangeSelectAddressActivity.class);
                break;
            case R.id.btn_back:
                finish();
                break;
        }
    }
}
